Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding 18_uruguay pre-alpha #10093

Closed

Conversation

patrikolesen
Copy link
Contributor

@patrikolesen patrikolesen commented Jan 4, 2024

Pre-alpha release of 18_uruguay

The basic building stones should now be in place but there are still some graphics that needs to be updated

Before clicking "Create"

  • Branch is derived from the latest master
  • Add the pins label if this change will break existing games
  • Code passes linter with docker compose exec rack rubocop -a
  • Tests pass cleanly with docker compose exec rack rake

Implementation Notes

  • Explanation of Change

  • Screenshots

  • Any Assumptions / Hacks

Copy link
Collaborator

@michaeljb michaeljb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry for the delay in this review, if I had looked at the PR closer to when it was opened I probably would have just closed it and asked to break it down into more manageable chunks.

If you want to address my comments piecewise, I recommend creating a new PR that has all of the config (maps/entity/etc constants, without any of the game logic or step classes, basically everything but new functions), and then separate PRs for separate features.

If you want to address the comments here instead of opening other PRs, it will make it easier for me to review the ongoing changes if you can keep the new individual commits focused on one feature and as small as possible.

Thanks for the contribution, I've heard great things about this game so it will be exciting to have a chance to play it on the site!

module Round
class Nationalization < Engine::Round::Operating
def after_end_of_turn(action)
super
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you planning on filling this out more in a later PR? If not it should be deleted.

module Game
module G18Uruguay
module Round
class Stock < Engine::Round::Stock
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing as with the Nationalization round--it's fine to keep this here if it will be needed in a later PR, otherwise it should be removed and the base round class used instead.


def check_and_apply_destination_bonus
corporation = current_entity.corporation
graph = @game.graph_for_entity(corporation)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking the graph on every lay tile action is expensive. Check out how 1822's destination token step works.

If the destination check does need to happen as part of the track step, this should at least be refactored so that the graph isn't rebuilt every time after the corporation has already received its second capitalization.

return [] if @game.final_operating_round?

@round.loan_taken |= false
actions = super.map(&:clone)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why actions = super doesn't work? This applies to some other steps too.


def process_take_loan(action)
entity = action.entity
@game.take_loan(entity, action.loan) unless @round.loan_taken
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would probably be best to raise a GameError if a loan already has been taken, to guarantee illegal actions can't be added to the DB.


def reset_adjustable_trains!(_entity, routes)
routes.each do |route|
p 'Find a way to clear train from good' if train_with_goods?(route.train)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be commented out until implemented, to avoid accidental logging to the console?

Suggested change
p 'Find a way to clear train from good' if train_with_goods?(route.train)
# p 'Find a way to clear train from good' if train_with_goods?(route.train)

end

def reset_train!(_train)
p 'Reset train!'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be commented out until implemented, to avoid accidental logging to the console?

Comment on lines +340 to +343
visits.each do |visit|
return true if PORTS.include?(visit.hex.id)
end
false
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's a more idiomatic loop you can use:

Suggested change
visits.each do |visit|
return true if PORTS.include?(visit.hex.id)
end
false
visits.any? { |visit| PORTS.include?(visit.hex.id) }

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same kind of change could be applied to route_include_port?


# LOANS
def init_loans
@loan_value = 100
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be pulled out to the top of the file as a constant instead of being an instance variable that is re-initialized every time this function is called?

end

def attach_good_to_train(train, hex)
train.name += '+' + @game.class::GOODS_TRAIN + '(' + hex.id + ')' if hex
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot of the code relating to train names is hard to read and understand, especially the regex parsing stuff. Is there another way that data about goods on the train could be stored, like an instance variable on the game class?

@michaeljb
Copy link
Collaborator

Closing this in favor of breaking it up into smaller pieces, e.g., #10194 and #10195

@michaeljb michaeljb closed this Jan 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants